Telegram Group & Telegram Channel
Common techniques for using the set() function in Python:

1. Create a set from a list:

my_list = [1, 2, 2, 3, 3, 3]
my_set = set(my_list)


2.Add an item to a set:

my_set = {1, 2, 3}
my_set.add(4)


3.Remove an item from a set by its value:

my_set = {1, 2, 3}
my_set.remove(3)


4.Check if an item is in a set:

my_set = {1, 2, 3}
if 3 in my_set:
print("The item is in the set.")


5.Get the length of a set:

my_set = {1, 2, 3}
set_length = len(my_set)


6.Loop through the items in a set:

my_set = {1, 2, 3}
for item in my_set:
print(item)


7.Get the union of two sets:

set1 = {1, 2, 3}
set2 = {3, 4, 5}
union_set = set1.union(set2)


8.Get the intersection of two sets:

set1 = {1, 2, 3}
set2 = {3, 4, 5}
intersection_set = set1.intersection(set2)

Share and Support
@Python_Codes



tg-me.com/python_codes/252
Create:
Last Update:

Common techniques for using the set() function in Python:

1. Create a set from a list:

my_list = [1, 2, 2, 3, 3, 3]
my_set = set(my_list)


2.Add an item to a set:

my_set = {1, 2, 3}
my_set.add(4)


3.Remove an item from a set by its value:

my_set = {1, 2, 3}
my_set.remove(3)


4.Check if an item is in a set:

my_set = {1, 2, 3}
if 3 in my_set:
print("The item is in the set.")


5.Get the length of a set:

my_set = {1, 2, 3}
set_length = len(my_set)


6.Loop through the items in a set:

my_set = {1, 2, 3}
for item in my_set:
print(item)


7.Get the union of two sets:

set1 = {1, 2, 3}
set2 = {3, 4, 5}
union_set = set1.union(set2)


8.Get the intersection of two sets:

set1 = {1, 2, 3}
set2 = {3, 4, 5}
intersection_set = set1.intersection(set2)

Share and Support
@Python_Codes

BY Python Codes


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_codes/252

View MORE
Open in Telegram


Python Codes Telegram | DID YOU KNOW?

Date: |

The lead from Wall Street offers little clarity as the major averages opened lower on Friday and then bounced back and forth across the unchanged line, finally finishing mixed and little changed.The Dow added 33.18 points or 0.10 percent to finish at 34,798.00, while the NASDAQ eased 4.54 points or 0.03 percent to close at 15,047.70 and the S&P 500 rose 6.50 points or 0.15 percent to end at 4,455.48. For the week, the Dow rose 0.6 percent, the NASDAQ added 0.1 percent and the S&P gained 0.5 percent.The lackluster performance on Wall Street came on uncertainty about the outlook for the markets following recent volatility.

How Does Bitcoin Mining Work?

Bitcoin mining is the process of adding new transactions to the Bitcoin blockchain. It’s a tough job. People who choose to mine Bitcoin use a process called proof of work, deploying computers in a race to solve mathematical puzzles that verify transactions.To entice miners to keep racing to solve the puzzles and support the overall system, the Bitcoin code rewards miners with new Bitcoins. “This is how new coins are created” and new transactions are added to the blockchain, says Okoro.

Python Codes from ar


Telegram Python Codes
FROM USA